package Jvm.Method;

public class ReferenceCountDome {
    /**
     * 测试引用计数器法（判断对象是否死亡）
     */
    public static void main(String[] args) {

//        测试前添加JVM参数（打印GC日志）-XX:+PrintGCDetails

//        测试引用计数器法（判断对象是否死亡）
        testGC();



    }

    public ReferenceCountDome instnce = null;
    private int _m = 1024 * 1024;
    private Byte[] bytes = new Byte[_m * 2];

    private static void testGC(){

        ReferenceCountDome objA = new ReferenceCountDome();
        ReferenceCountDome objB = new ReferenceCountDome();

        objA.instnce = objB;
        objB.instnce = objA;

        System.gc();

    }

}
